#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;

LL m, n;
LL a[N], b[N];

int main()
{
	cin >> m >> n;
	for(int i = 1;i <= m;i ++) cin >> a[i];
	LL ans = 0;
	sort(a + 1, a + 1 + m);
	while(n --)
	{
		LL x; cin >> x;
		auto it = lower_bound(a + 1, a + 1 + m, x);
		if(it == a + 1) ans += abs(*it - x);
		else ans += min(abs(*it - x), abs(*(it - 1) - x));
	}
	cout << ans << endl;
	return 0;
}